/** 
* @file vmu_pde.h
* Page Directory Entries (PDE) header declarations.
* Provides abstraction interface to aid in managment of PDEs.
* Page Directory Entry is what represent PAGE TABLE.
* Page Table is array of Pages (PTEs). It is 32 bit structure
* where frame parameter pointing to address whete Page Table array begins.
*
* Copyrights 2010 Michal Saman, m.saman@designplus.cz.
* This source code is release under the Apache License 2.0.
* http://www.apache.org/licenses/LICENSE-2.0
*/

#ifndef _VMU_PDE_H
#define _VMU_PDE_H

#include <stdint.h>
#include <mem/pmu.h>

/** Page Directory Entry - flags for descripting one Page Table */
enum PAGE_PDE_FLAGS {
	PDE_PRESENT			= 1,		/**< Present flag, is Page Table in memory? */
	PDE_WRITABLE		= 2,		/**< Read/Write flag */
	PDE_USER			= 4,		/**< Usermode/Supervisor mode flag */
	PDE_PWT				= 8,		/**< Write throught/Write back caching flag */
	PDE_PCD				= 0x10,		/**< Cache disbled flag */
	PDE_ACCESSED		= 0x20,		/**< Access flag, set by processor */
	PDE_DIRTY			= 0x40,		/**< Dirty flag, set by processor */
	PDE_4MB				= 0x80,		/**< Contained pages size, 4kB or 4MB */
	PDE_CPU_GLOBAL		= 0x100,	/**< Global flag, ignored */
	PDE_LV4_GLOBAL		= 0x200,	/**< Available for use */
	PDE_FRAME			= 0xFFFFF000	/**< Page Table base address */
};

/** Page directory entry data type - represinting one PAGE TABLE */
typedef uint32_t	pde;

extern void pde_add_attrib(pde *e, uint32_t attrib);
extern void pde_del_attrib(pde *e, uint32_t attrib);
extern void pde_set_frame(pde *e, physical_addr addr);
extern bool pde_is_present(pde e);
extern bool pde_is_user(pde e);
extern bool pde_is_4mb(pde e);
extern bool pde_is_writable(pde e);
extern physical_addr pde_get_frame(pde e);
//extern void pde_enable_global(pde e);

#endif
